package com.swu.common;

import io.swagger.v3.oas.annotations.media.Schema;
import lombok.Data;

@Data
@Schema(description = "通用响应结果")
public class Result<T> {
    
    @Schema(description = "状态码：1-成功，0-失败")
    private Integer code;
    
    @Schema(description = "提示信息")
    private String message;
    
    @Schema(description = "响应数据")
    private T data;
    
    private Result(Integer code, String message, T data) {
        this.code = code;
        this.message = message;
        this.data = data;
    }
    
    public static <T> Result<T> success(T data) {
        return new Result<>(1, "success", data);
    }
    
    public static <T> Result<T> error(String message) {
        return new Result<>(0, message, null);
    }

    public static <T> Result<T> error(String message, T data) {
        return new Result<>(0, message, data);
    }
} 